package code.structure.module.scene.view.layer
{
	import code.untils.SceneConfig;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	
	/**
	 *夹缝层 （在地板层在物件层中间） 
	 * @author Yuri
	 * 
	 */
	public class CrackLayer extends Sprite
	{
		/**
		 *高亮区块区域 
		 */
		private var _highlightArea:Shape;
		public function CrackLayer()
		{
			super();
		}
		
		/**
		 *显示高亮区域 
		 * @param isShow 是否显示
		 * @param xPosition 坐标
		 * @param yPosition
		 * 
		 */
		public function showHighlightArea(isShow:Boolean = true,xPosition:Number=0,yPosition:Number=0):void{
			if(isShow){
				if(!_highlightArea){
					var _xLength:int = SceneConfig.WORLD_GRID_SIZE * SceneConfig.WORLD_AREA_LENGTH;
					var _zLength:int = SceneConfig.WORLD_GRID_SIZE * SceneConfig.WORLD_AREA_LENGTH;
					_highlightArea = new Shape();
					_highlightArea.graphics.clear();
					_highlightArea.graphics.lineStyle(4,0xff9900);
					_highlightArea.graphics.lineTo(0, 0);
					_highlightArea.graphics.lineTo(_xLength, _zLength * .5);
					_highlightArea.graphics.lineTo(0, _zLength);
					_highlightArea.graphics.lineTo(-_zLength, _zLength * .5);
					_highlightArea.graphics.lineTo( 0, 0);
					_highlightArea.graphics.endFill();
				}
				addChild(_highlightArea);
				_highlightArea.x = xPosition;
				_highlightArea.y = yPosition;
			}else{
				if(_highlightArea && contains(_highlightArea)){
					removeChild(_highlightArea);
				}
			}
		}
	}
}